package chapter5

import (
	"fmt"
	"strings"
	"unicode/utf8"
	"unsafe"
)

func stringOperator(s string)  {
	tempstr:="sss"
	fmt.Println(tempstr!=s)
	fmt.Println(tempstr==s)
	fmt.Println(tempstr>s)
	fmt.Println(tempstr+s)

}

func Test1()  {
	//可以用·来定义不做转义处理的原始字符串，同时还支持跨行
	s:=`ss/ns
        ddddd
            dddd`
	fmt.Println(s)
	str:="sssss/nssss"
	fmt.Println(str)
	fmt.Println("------------------------")
	//支持！=，==，<,>,+,+=等操作符
	stringOperator("wnag")
	fmt.Println("------------------------")
	num1:=[]int{1,2,3,4}
	num2:=num1[1:]//虽然从中截取了，但是依旧指向底层的数组
	fmt.Println(&num1[1],&num2[0])
	fmt.Println("------------------------")
	name:="小钢炮"
	for i:=0;i<len(name);i++{
		fmt.Printf("%c\n",name[i])
	}
	for _,v:=range name{//用rune方式遍历
		fmt.Printf("%c\n",v)
	}
	fmt.Println("------------------------")
	bs:=[]byte("12345")
	bs=append(bs,"789"...)
	fmt.Println(*(*string)(unsafe.Pointer(&bs)))
	fmt.Println("-------------------------")
	strsum:=make([]string,1000)
	for i:=0;i<100;i++{
		strsum[i]="a"
	}
	fmt.Println(strings.Join(strsum,""))
	fmt.Println("--------------------")
	str1:="wang"
	str2:="li"
	fmt.Println(strings.Join([]string{str1,str2},""))
	fmt.Println("--------------------")
	sl:="li"
	bs=[]byte(sl)
	fmt.Printf("%T",bs[0])
	fmt.Println("------------------------")
	chinese:="王。liss"
	fmt.Println(utf8.RuneCountInString(chinese))

}